package com.atguigu.gmall.activity.config;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * title:
 * author: Gyh
 * date:2023-05-14 11:10
 * Description:
 */
@Configuration
public class CaffineeCacheConfig {

    /**
     * 秒杀商品状态本地缓存对象
     * @return
     */
    @Bean
    public Cache<String,String> seckillCache(){
        return Caffeine.newBuilder()
                .expireAfterWrite(24, TimeUnit.HOURS)
                .maximumSize(500)
                .build();
    }
}
